package com.sc.byahi.user.client;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.user.client.ui.Composite;
import com.sc.byahi.user.shared.Profile;

public abstract class ProfileResultView extends Composite implements ICleaner {
	protected Map<Long, Profile> currProfiles = new HashMap<Long, Profile>();
	protected boolean ownData = false;

	@Override
	public void clean() {
		currProfiles.clear();
	}

	protected List<Long> data = new ArrayList<Long>();

	public boolean isDataEmpty() {
		return data.isEmpty();
	}

	boolean isMap = false;

	/**
	 * This one cleans old data also.
	 * 
	 * @param data
	 */
	public void setData(List<Long> data, boolean isOwnData) {
		clean();// Should call subclass method
		if (data != null)
			this.data = data;
		this.ownData = isOwnData;
		redrawView();
	}

	/**
	 * Only redraw view, don't clean cached profile data
	 */
	public abstract void redrawView();

	/**
	 * Only redraw part of view which shows this profile.
	 */
	public abstract void redrawProfile(Profile profile);

	public abstract void hideProfile(Long id);
}
